package com.qztech.sdk.model.entities;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;

import java.util.Arrays;


/**
 * @author:zhanghb
 * @date:2019/2/26
 * @email:2573475062@qq.com
 **/
@Entity(tableName = "delay_channel")
public class DelayChannel implements Cloneable{
    @PrimaryKey(autoGenerate = true)
    private long id;

    @ColumnInfo(name = "channel")
    protected int channel;

    @Ignore
    private int[] delay = new int[6];

    @Ignore
    private int[] volume = new int[6];

    @Ignore
    private int[] xover = new int[]{1,1,1,1,1,1,1};

    @ColumnInfo(name = "delay_val")
    private String delayVal;

    @ColumnInfo(name = "xover_vol")
    private String xoverVol;

    @ColumnInfo(name = "vol_val")
    private String vol;

    @ColumnInfo
    private String pid;

    public DelayChannel() {
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public int getChannel() {
        return channel;
    }

    public void setChannel(int channel) {
        this.channel = channel;
    }

    public int[] getDelay() {
        return delay;
    }

    public void setDelay(int[] delay) {
        this.delay = delay;
    }

    public String getDelayVal() {
        return delayVal = Arrays.toString(delay);
    }

    public void setDelayVal(String delayVal) {
        this.delayVal = delayVal;
        if (delayVal == null || delayVal.length() <= 0) return;
        String[] tempGain = delayVal.replace("[", "").replace("]", "").split(",");
        this.delay = new int[tempGain.length];
        try {
            for (int i = 0; i < tempGain.length; i++) {
                this.delay[i] = Integer.parseInt(tempGain[i].trim());
            }
        } catch (Exception ex) {
            System.out.println(" setDelay ERROR:" + ex);
        }
    }

    public String getVol() {
        return vol = Arrays.toString(volume);
    }

    public void setVol(String vol) {
        this.vol = vol;
        if (vol == null || vol.length() <= 0) return;
        String[] tempGain = vol.replace("[", "").replace("]", "").split(",");
        this.volume = new int[tempGain.length];
        try {
            for (int i = 0; i < tempGain.length; i++) {
                this.volume[i] = Integer.parseInt(tempGain[i].trim());
            }
        } catch (Exception ex) {
            System.out.println(" setXover ERROR:" + ex);
        }
    }

    public int[] getVolume() {
        return volume;
    }

    public void setVolume(int[] volume) {
        this.volume = volume;
    }

    public int[] getXover() {
        return xover;
    }

    public void setXover(int[] xover) {
        this.xover = xover;
    }

    public String getXoverVol() {
        return xoverVol = Arrays.toString(xover);
    }

    public void setXoverVol(String xoverVol) {
        this.xoverVol = xoverVol;
        if (xoverVol == null || xoverVol.length() <= 0) return;
        String[] tempGain = xoverVol.replace("[", "").replace("]", "").split(",");
        this.xover = new int[tempGain.length];
        try {
            for (int i = 0; i < tempGain.length; i++) {
                this.xover[i] = Integer.parseInt(tempGain[i].trim());
            }
        } catch (Exception ex) {
            System.out.println(" setXover ERROR:" + ex);
        }
    }

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
